//
//  LssMainTabbarController.swift
//  freeChatting
//
//  Created by mac on 16/4/16.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class LssMainTabbarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabbar = LssTabbar()
        tabbar.tabbarDelegate = self
        setValue(tabbar, forKey: "tabBar")
        //添加子控制器
        addChildViewController(LssHomeController(), imageName: "tabbar_home", title: "首页")
        addChildViewController(LssMessageController(), imageName: "tabbar_message_center", title: "消息")
        addChildViewController(LssDiscoverController(), imageName: "tabbar_discover", title: "发现")
        addChildViewController(LssMineController(), imageName: "tabbar_profile", title: "我的")
        
    }
    //Mark:添加子控制器
    func addChildViewController(childController: UIViewController,imageName: String, title: String) {
        childController.tabBarItem.image=UIImage(named: imageName)
        childController.tabBarItem.selectedImage=UIImage(named: "\(imageName)_selected")
        childController.title=title
        addChildViewController(UINavigationController(rootViewController: childController))
    }
}
//Mark:tabbar的代理方法
extension LssMainTabbarController: LssTabbarDelegate{
    func clickComposeButton() {
        print("撰写按钮被点击了")
    }
}
